/**
 * @author xinjie.txt
 * @time: 2020年7月9日 下午11:07:22
 */
package com.jiepu.exercise.primary.chapter5.exercise6;

import java.util.Scanner;

/**
 * @Description:
 * @author xinjie.txt
 */
public class TeaStuMain {

	public static void main(String[] args) {
		// 账户初始化
		Teacher[] teachers = new Teacher[3];
		Teacher teacher1 = new Teacher(2001, "张三", 40, "男", 20000.00);
		Teacher teacher2 = new Teacher(2002, "李四", 35, "女", 15000.00);
		Teacher teacher3 = new Teacher(2003, "王五", 30, "男", 10000.00);
		teachers[0] = teacher1;
		teachers[1] = teacher2;
		teachers[2] = teacher3;
		Student[] students = new Student[4];
		Student student1 = new Student(1001, "Tom", "男", 22, "tom1314", "tompwd123", teacher1);
		Student student2 = new Student(1002, "Jack", "男", 22, "j885983", "jackiou", teacher2);
		Student student3 = new Student(1003, "Lucy", "女", 23, "lucy321", "112233", teacher1);
		Student student4 = new Student(1004, "Lily", "女", 21, "ll8888", "ll8888", teacher3);
		students[0] = student1;
		students[1] = student2;
		students[2] = student3;
		students[3] = student4;

		// choose identity

		// 循环登录
		boolean islogin = false;
		while (!islogin) {

			// login in

			Scanner scacc = new Scanner(System.in);
			Scanner scpwd = new Scanner(System.in);
			System.out.println("Input account: ");
			String account = scacc.next();
			System.out.println("Input password: ");
			String password = scpwd.next();
			scacc.close();
			scpwd.close();

			for (int i = 0, len = students.length; i < len; i++) {
				if (account.equals(students[i].getAccount()) == true
						&& password.equals(students[i].getPassword()) == true) {
					students[i].toString();
				} else {
					System.out.println("mistake");
					islogin = true;
					break;
				}
			} // for
		} // while
	} // main
}
